package Lab03;



import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class TestMain {
    public static final String sql = "select password,count(password) from db_csdn.csdn group by password order by count(password) desc limit 10;";
    public static void main(String[] args) throws SQLException {
        Connection con = DBCP.getConnection();
        PreparedStatement ps = con.prepareStatement(sql);
        ResultSet resultSet = ps.executeQuery();
        System.out.println("密码"+"\t\t"+"次数(降序)");
        while (resultSet.next()){
            System.out.println(resultSet.getString("password")+"\t\t"+resultSet.getString("count(password)"));
        }
        ps.close();
    }

}
/*
* 运行结果：
* 密码		      次数(降序)
* 123456789 	235029
* 12345678 		212761
* 11111111 		76348
* dearbook 		46054
* 00000000 		34953
* 123123123 	20010
* 1234567890 	17794
* 88888888 		15033
* 111111111 	6995
* 147258369 	5966

* */